//
// Created by gastonfeng on 2022/11/21.
//

#ifndef RTE_KB1288_USB_SERIAL_H
#define RTE_KB1288_USB_SERIAL_H

#include <USBSerial.h>
#include "nStream.h"
#include "kSerial.h"

class USB_Serial : public kSerial {
public:
    USB_Serial() = default;

    ~USB_Serial() override = default;

    int sleep() override;

    void resume();

    int read_wait(int timeout = -1) override;

    void begin(uint32_t, uint8_t);

    int availableForWrite() override;

    int write(const uint8_t *buffer, int size) override;

    int write(uint8_t ch) final;

#ifndef THIS_IS_BOOTLOADER
    int end() override;
#endif
    void flush() override;

    void dtr(bool enable);

    bool dtr();

    bool rts();

    void begin(void);

    void begin(uint32_t);

    int available(void);

    int read(void);

    void *rxlock;

    bool disconnected();
//    pb_userial_info data;
};

#endif // RTE_KB1288_USB_SERIAL_H
